package ar.com.framenet.base.config;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Es un bean comun y corriente, que tiene un hashmap para manejar atributos
 * dinamicos. Solo difiere del AttributesObject en que tienen otros nombres los
 * metodos
 * 
 * @author sam
 */
@SuppressWarnings({ "rawtypes", "serial", "unchecked" })
public class PropertyBean implements Serializable {

	private Map properties = new HashMap();

	/**
	 * 
	 */
	public PropertyBean() {
		super();
	}

	/**
	 * 
	 */
	public PropertyBean(Map properties) {
		super();
		if (properties != null) {
			this.properties = properties;
		}
	}

	/**
	 * Realiza el ToString del objeto
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return this.getClass().getName() + ": Properties=" + this.getProperties();
	}

	/**
	 * Realiza el equals de este objeto
	 * 
	 * @see java.lang.Object#equals()
	 */
	public boolean equals(Object obj) {
		PropertyBean other = null;
		try {
			other = (PropertyBean) obj;
			return this.getProperties() == other.getProperties();
		} catch (ClassCastException exc) {
			return false;
		}
	}

	/**
	 * @return
	 */
	public Map getProperties() {
		return properties;
	}

	/**
	 * 
	 */
	public void clear() {
		properties.clear();
	}

	/**
	 * @param arg0
	 * @return
	 */
	public boolean containsKey(String name) {
		return properties.containsKey(name);
	}

	/**
	 * @param arg0
	 * @return
	 */
	public boolean containsValue(Object arg0) {
		return properties.containsValue(arg0);
	}

	/**
	 * @param arg0
	 * @return
	 */
	public Object getProperty(String name) {
		return properties.get(name);
	}

	/**
	 * @return
	 */
	public boolean isEmpty() {
		return properties.isEmpty();
	}

	/**
	 * @param arg0
	 * @param arg1
	 * @return
	 */
	public Object setProperty(String name, Object arg1) {
		return properties.put(name, arg1);
	}

	/**
	 * @param arg0
	 * @return
	 */
	public Object remove(String param) {
		return properties.remove(param);
	}

	/**
	 * @return
	 */
	public int size() {
		return properties.size();
	}

	/**
	 * @param map
	 */
	protected void setProperties(Map map) {
		properties = map;
	}
}